package com.tdkj.service.user.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.tdkj.dao.user.IBeanUserDao;
import com.tdkj.model.user.BeanFriend;
import com.tdkj.model.user.BeanUser;
import com.tdkj.service.BaseService;
import com.tdkj.service.user.IBeanUserService;
import com.tdkj.util.md5.MD5Util;

@Component("userService")
public class BeanUserServiceImpl extends BaseService  implements IBeanUserService{
	private  IBeanUserDao beanUserDao;
	
	@Resource
	public void setBeanUserDao(IBeanUserDao beanUserDao) {
		this.beanUserDao = beanUserDao;
	}

	@Override
	public BeanUser getUser(long userId) {
		BeanUser user = beanUserDao.findById(userId, BeanUser.class);
		//user.getEnterprise();
		//user.getEnterpriseZone();
		return user;
	}

	@Override
	public String addUser(Long uId, Long fId) {
		String info="";
		BeanUser u =  beanUserDao.findById(uId, BeanUser.class);
		BeanUser f =  beanUserDao.findById(fId, BeanUser.class);
		beanUserDao.save(u);
		return info;
	}

	@Override
	public void updatePassword(Long userId, String password) {
		BeanUser bean =  beanUserDao.findById(userId, BeanUser.class);
		bean.setUserpassword(MD5Util.md5Encrypt(password));
	}

	@Override
	public boolean isExist(Long userId, String password) {
		BeanUser bean =  beanUserDao.findById(userId, BeanUser.class);
		return bean.getUserpassword().equals(MD5Util.md5Encrypt(password));
	}

}
